Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

109
Visualizações
Firebase Realtime Database - "Error: Client is offline". React/NextJS

Using React with NextJS the following error occurs occasionally when fetching data from a Firebase Realtime Database.

Unhandled Runtime Error
Error: Error: Client is offline.

I am using Firebase 9.0.1 for React.

Top Level code for intialisation and config

import { initializeApp } from "firebase/app";
import { getDatabase, ref, onValue, child, get } from "firebase/database";
import CONFIG from '../CONFIG.json'


const FIREBASE_CONFIG = {
  apiKey: CONFIG['FIREBASE_API_KEY'],
  authDomain: CONFIG['FIREBASE_AUTH_DOMAIN'],
  databaseURL: CONFIG['FIREBASE_DATABASE_URL'],
  storageBucket: CONFIG['FIREBASE_STORAGE_BUCKET']

}
const fbApp = initializeApp(FIREBASE_CONFIG)

And later fetching data

export default function Leads() {
  ...

  useEffect(() => {
    const database = getDatabase(fbApp)
    const ads = ref(database, 'ad_results')

    get(ads).then((snap) => {
      const results = snap.val()
      ...

I have tried searching similar issues but to no avail, any help would be appreciated.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I had the same issue with my Cloud Functions, which was very confusing. After some hours of debugging, I found out that the .get() method of the Realtime Database was causing this problem. My current workaround is to use instead .once('value').

So I changed my code from:

await database.ref(`foo/bar`).get();

to

await database.ref(`foo/bar`).once('value');
about 4 years ago · Juan Pablo Isaza Relatório

0

I am using firebase nodejs SDK, also facing the same error: "Error: Error: Client is offline." occasionally.

I have tried the above solution posted by Nils Reichardt. It works for me.

Thanks Nils!

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda